package com.keur.money.ui.main.adapter

import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.keur.money.R
import com.keur.money.base.adapter.MullaRecyclerViewAdapter
import com.keur.money.base.adapter.MullaViewHolderHelper
import org.json.JSONObject

/**
 * MullaFlow
 * @Author wwdeng
 * @CreateTime: 2024/7/26 16:42
 * @Annotation：Tab适配器
 */

class KeurTabAdapter(recyclerView: RecyclerView?) : MullaRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.item_mulla_tab) {
    override fun setItemChildListener(helper: MullaViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.itemLayout) //点击Item
    }

    override fun fillData(helper: MullaViewHolderHelper, position: Int, model: JSONObject) {
        val imgNormal = helper.getImageView(R.id.imgNormal)
        val imgSelected = helper.getImageView(R.id.imgSelected)
        imgNormal.setImageResource(model.optInt("tabImageNormal"))
        imgSelected.setImageResource(model.optInt("tabImageSelected"))
        when(model.optBoolean("isSelect", false)){
            true -> {
                imgSelected.visibility = View.VISIBLE
            }
            else -> {
                imgSelected.visibility = View.GONE
            }
        }
    }
}